<?php

namespace app\admin\validate\tyyh;

use app\common\validate\tyyh\UserWallet as ParentUserWallet;

class UserWallet extends ParentUserWallet
{
	/**
     * 验证规则
     */
    protected $rule = [
        'lock'              => 'require',
        'id'                => 'require|isOperate',
        'remark'            => 'max:100'
    ];


    /**
     * 提示消息
     */
    protected $message = [
        'lock.require'                  => '验证规则场景不存在',
        'id.require'                    => '退款单ID不能为空',
        'id.isOperate'                  => '退款单是否可以操作',
        'remark.max'                    => '备注不能超过100个字符'
    ];
    /**
     * 验证场景
     */
    protected $scene = [
        'operate'         => ['id', 'remark']
    ];

    protected function isOperate($value, $rule, $data = []) {
        $row = loader('admin')->loadAny('only', 'tyyh\\UserWalletBalanceRefund')->get_row($value);
        return $row['status'] == 0;
    }
}